var common_util={
    // ----------------------------------------token操作-------------------------------
// 获取token检验
    takeAccessToken:()=>{
        // const str=localStorage.getItem('Authorization')||sessionStorage.getItem('Authorization');
        const str=sessionStorage.getItem('Authorization');
        if(!str){return null}
        const authObj=JSON.parse(str);
        // 日期检验
        // if(authObj.expire<=new Date().getTime()) {
        //     deleteAccessToken()
        //     console.log("已过期")
        //     return null
        // }
        return authObj
    },
    // 储存token
    storeAccessToken:(token)=>{
        const authObj={
            token:token
        }
        const str=JSON.stringify(authObj);
        sessionStorage.setItem('Authorization',str);
    },
    //删除token
    deleteAccessToken:()=>{
        localStorage.removeItem('Authorization')
        sessionStorage.removeItem('Authorization')
    },
    // 将token写入header
    accessHeader:function(){
        const token =this.takeAccessToken();
        return token?{
            'Content-Type': 'application/json',
            'Authorization':`Bearer ${token.token}`
        }:{'Content-Type': 'application/json'}
    },
    moreHeader:function(contentType){
        const token=this.takeAccessToken();
        return token?{
            'Content-Type': contentType,
            'Authorization':`Bearer ${token.token}`
        }:{'Content-Type': contentType}
    }
}
export default common_util;